<?php

class Asignatura{
	
	public $bd;
	public $resultado;

	
	public function __construct(){
		
		$this->bd = new Basedatos();
		
	}
		public function mostrar_asignatura(){
		
		$query = "CALL ConsultarTodasAsignatura()";
		$this->result = $this->bd->select($query);
		return $this->result;
	}
		public function ingresar_asignatura($nom, $desc){
		
		$query = "CALL IngresarAsignatura('".$nom."', '".$desc."')";
		$this->result = $this->bd->insert($query);		
	}
		public function editar_asignatura($id, $nombre, $descr){
			$query = "CALL ModificarAsignatura('".$id."', '".$nombre."', '".$descr."')";
			$this->result = $this->bd->update($query);	
		}
		public function eliminar_asignatura($id){
			$query = "CALL EliminarAsignatura('".$id."')";
			$this->result = $this->bd->delete($query);	
		}
		public function mostrar_asignatura_uno($id){
			$query = "CALL ConsultarUnaAsignatura('".$id."')";
			$this->result = $this->bd->select($query);
			return $this->result;
		}
		public function existe_asignatura($id){
			$query = "CALL ExisteAsignatura('".$id."')";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
		public function relacion_asignatura($id){
			$query = "CALL RelAsigUsu('".$id."')";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}		
}

?>